using System;
using System.Web.UI;
using System.Collections.Generic;
using System.Text;

namespace CustomControls
{
    internal class Utility
    {
        /// <summary>
        /// Finds a control recursively
        /// </summary>
        /// <param name="Root"></param>
        /// <param name="controlID"></param>
        /// <returns></returns>
        internal static Control FindControl(Control Root, string controlID)
        {
            try
            {
                if (Root.ID == controlID)
                {
                    return Root;
                }

                foreach (Control c in Root.Controls)
                {
                    Control ctrl = FindControl(c, controlID);
                    if (ctrl != null)
                    {
                        return ctrl;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.ToString());
            }

            return null;
        }
    }
}
